package com.github.trie;

import org.apache.commons.collections4.Trie;
import org.apache.commons.collections4.trie.PatriciaTrie;
import org.junit.jupiter.api.Assertions;

import static org.junit.jupiter.api.Assertions.assertEquals;

/**
 * @author zhangcheng
 * @date 2022/10/10 17:19
 * @description
 */
public class TrieTest {

    public static void main(String[] args) {
        Trie<String, String> trie = new PatriciaTrie<>();
        trie.put("Abigail", "student");
        trie.put("Abi", "doctor");
        trie.put("Annabel", "teacher");
        trie.put("Christina", "student");
        trie.put("Chris", "doctor");
        Assertions.assertTrue(trie.containsKey("Abigail"));
        assertEquals("{Abi=doctor, Abigail=student}", trie.prefixMap("Abi").toString());
        assertEquals("{Chris=doctor, Christina=student}", trie.prefixMap("Chr").toString());
    }

}
